package com.icbc.dccsh.functions;

import java.util.ArrayList;

import net.objecthunter.exp4j.function.Function;

public class AverageFunction extends Function {
	public AverageFunction(){
		super("average", 1);
	}
	
	@Override
	public double apply(Object... arg) {
		ArrayList<Double> li = (ArrayList<Double>)arg[0];
		Double sum = 0d;
		for(Object d : li){
			sum += Double.parseDouble(d.toString());
		}
		return sum / li.size();
	}
}